.TH std::ranges::common_view::end 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::ranges::common_view::end \- std::ranges::common_view::end

.SH Synopsis
   constexpr auto end() requires (!__simple_view<V>);          \fB(1)\fP \fI(since C++20)\fP
   constexpr auto end() const requires ranges::range<const V>; \fB(2)\fP \fI(since C++20)\fP

   1) Returns an iterator representing the end of the common_view, that is:
     * ranges::begin(base_) + ranges::size(base_), if both
       ranges::random_access_range<V> and ranges::sized_range<V> are satisfied,
     * std::common_iterator<ranges::iterator_t<V>,
       ranges::sentinel_t<V>>(ranges::end(base_)) otherwise.
   Here base_ (the name is for exposition purposes only) is the underlying view.
   2) Same as \fB(1)\fP, but V is const-qualified.

.SH Parameters

   \fI(none)\fP

.SH Return value

   An iterator representing the end of the underlying view.

.SH Example


// Run this code

 #include <iostream>
 #include <numeric>
 #include <ranges>

 int main()
 {
     constexpr int n{4};

     constexpr auto v1 = std::views::iota(1)
                       | std::views::take(n)
                       | std::views::common
                       ;
     constexpr auto v2 = std::views::iota(2)
                       | std::views::take(n)
                       ;
     const int product = std::inner_product(v1.begin(), v1.end(),
                                            v2.begin(),
                                            0);
     std::cout << product << '\\n';
 }

.SH Output:

 40

   Defect reports

   The following behavior-changing defect reports were applied retroactively to
   previously published C++ standards.

      DR    Applied to            Behavior as published            Correct behavior
   LWG 4012 C++20      non-const overload missed simple-view check added

.SH See also

   begin         returns an iterator to the beginning
   (C++20)       \fI(public member function)\fP
   ranges::begin returns an iterator to the beginning of a range
   (C++20)       (customization point object)
   ranges::end   returns a sentinel indicating the end of a range
   (C++20)       (customization point object)
